//index.js
//获取应用实例
const app = getApp()
var util = require("../../../../utils/util.js")
Page({
  data: {
    xianzhi: true,
    motto: 'Hello World',
    userInfo: {},
    hasUserInfo: false,
    canIUse: wx.canIUse('button.open-type.getUserInfo'),
    sheet: 0,
    dateil: '对于白血病，根据其不同的时期，治愈的概率也是不一样的，化疗的治愈率大体为40% 左右，白血病是一类造血白细胞',
    voiceList: [{
        poster: "https://6a69-jin5201-a4503e-1257013711.tcb.qcloud.la/doctorDetail/voice.png?sign=913e72f8319b2ac8de6dc1cec669c976&t=1580888655",
        title: "婴幼儿如何预防流感？",
        doctor: "李伟",
        doctorImg: "",
        time: "2020-2-5",
        src: "http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46"
      },
      {
        poster: "https://6a69-jin5201-a4503e-1257013711.tcb.qcloud.la/doctorDetail/voice.png?sign=913e72f8319b2ac8de6dc1cec669c976&t=1580888655",
        title: "婴幼儿如何预防流感？",
        doctor: "李伟",
        doctorImg: "",
        time: "2020-2-5",
        src: "http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46"
      },
    ],
    article: [{
        title: "婴幼儿如何预防流感？",
        doctor: "李伟",
        doctorImg: "",
        time: "2020-2-5",
      },
      {
        title: "婴幼儿如何预防流感？",
        doctor: "李伟",
        doctorImg: "",
        time: "2020-2-5",
      },
      {
        title: "婴幼儿如何预防流感？",
        doctor: "李伟",
        doctorImg: "",
        time: "2020-2-5",
      },
    ]
  },

  // 显示更多信息
  morebtns() {
    this.setData({
      xianzhi: false
    })
  },
  // 打开地图
  openoaction(e) {
    wx.openLocation({
      latitude: parseFloat(e.currentTarget.dataset.latitude),
      longitude: parseFloat(e.currentTarget.dataset.longitude),
      address: e.currentTarget.dataset.address,
      scale: 22
    });
  },
  //打电话
  tellsbtn(e) {
    var tel = e.currentTarget.dataset.tel;
    wx.makePhoneCall({
      phoneNumber: tel,
    })
  },
  docinfo(e) {
    var that = this
    var zid = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/hyb_yl/czhuanjiasubpages/pages/zhuanjiazhuye/zhuanjiazhuye?zid=' + zid,
    })
  },


  onLoad: function (options) {
    var that = this;
    var hid = options.hid
    var color = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: '#ffffff',
      backgroundColor: color,
    })
    let dateil = this.data.dateil.slice(0, 40) + '...'
    that.setData({
      hid: hid,
      color: color
    })
    that.getHospital_info();
  },
  getHospital_info: function () {
    var that = this;
    app.util.request({
      'url': 'entry/wxapp/jiansuo.hospital_info',
      'data': {
        hid: that.data.hid
      },
      success: function (res) {
        that.setData({
          info: res.data
        })
      },
    })
  },
  onShareAppMessage(ops) {
    console.log(ops)
    //更新数据库
    var that = this
    var hid = that.data.hid
    app.util.request({
      'url': 'entry/wxapp/index.updatetuikehosp',
      data: {
        hid: hid,
        openid: wx.getStorageSync('openid')
      },
      success: function (res) {
        console.log(res)
      }
    })
    return {
      title: '分享卡片',
      path: 'hyb_yl/mycenter/pages/organApply/organApply?openid=' + wx.getStorageSync('openid'),
      success: function (res) {
        // 转发成功
        console.log("转发成功:" + res);

      },
      fail: function (res) {
        // 转发失败
        console.log("转发失败:" + res);
      }
    }
  },
  onShareTimeline(ops) {

  }
})